<template>
  <view>
    <view class="item" v-for="item in Data" :key="item.id">
      <icon type="waiting" size="20" />
      <view class="line"></view>
      <view>
        <text
          class="tab"
          v-if="item.state == 1"
          style="background: #ffff99; color: black"
        >
          【发布】
        </text>
        <text
          class="tab"
          v-if="item.state == 2"
          style="background: #ff6699; color: white"
        >
          【采纳】
        </text>
        <text
          class="tab"
          v-if="item.state == 3"
          style="background: #66ccff; color: white"
        >
          【充值】
        </text>
        <text
          class="tab"
          v-if="item.state == 4"
          style="background: #ccffcc; color: green"
        >
          【签到】
        </text>
        <text
          class="tab"
          v-if="item.state == 5"
          style="background: #ff0000; color: white"
        >
          【下商品订单】
        </text>
        <text
          class="tab"
          v-if="item.state == 6"
          style="background: #990099; color: white"
        >
          【下预约订单】
        </text>
        <text
          class="tab"
          v-if="item.state == -1"
          style="background: #66cccc; color: white"
        >
          【退款】
        </text>
        <text class="money">{{ item.point ? item.point : 0 }}元</text>
      </view>
      <text>{{ item.createtime }}</text>
    </view>
  </view>
</template>

<script>
export default {
  onShow() {
    this.$u.auth.check()

    //获取本地存储的信息
    let LoginUser = uni.getStorageSync('LoginUser')

    this.LoginUser = LoginUser

    this.recordData()
  },
  data() {
    return {
      LoginUser: null,
      Data: [],
    }
  },
  methods: {
    async recordData() {
      let data = {
        createtime: this.selTime,
        userid: this.LoginUser.id
      }

      let result = await this.$u.api.user.RecordData(data)
      // console.log(result);

      if (result.code === 0) {
        this.$refs.uNotify.show({
          type: 'error',
          message: result.msg,
          duration: 1500
        })
        return false
      }

      this.Data = result.data
    }
  }
}
</script>

<style>
/* pages/record/record.wxss */
page {
  background-color: rgb(247, 247, 247);
}
.item {
  margin: 50rpx 80rpx 50rpx 130rpx;

  border-bottom: 1rpx solid #ccc;
  position: relative;
  padding: 10rpx 20rpx;
  box-shadow: 0 0 20rpx #ddd;
  border-radius: 4rpx;
}
.item icon {
  position: absolute;
  left: -71rpx;
  top: 45rpx;
  z-index: 3;
}
.item view {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 34rpx;
  margin: 10rpx 0;
}
.item view .money {
  font-size: 28rpx;
}
.item > text {
  font-size: 26rpx;
}
.line {
  position: absolute;
  width: 2rpx;
  height: 200rpx;
  background-color: rgb(78, 169, 245);
  left: -51rpx;
  top: 41rpx;
  z-index: 2;
}
</style>